import { request } from '@/utils/requestWrapper';

import type { API } from '@/backend/typings.d';

/** 添加商品 POST /api/product/add */
export async function addProductUsingPost(
  body: API.ProductAddRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLong_>({
    url: "/api/product/add",
    method: "POST",
    data: body,
    ...options
  });
}

/** 删除商品 POST /api/product/delete */
export async function deleteProductUsingPost(
  body: API.DeleteRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>({
    url: "/api/product/delete",
    method: "POST",
    data: body,
    ...options
  });
}

/** 获取商品详情 GET /api/product/get/vo */
export async function getProductVoByIdUsingGet(
  params: {
    id: number;
  },
  options?: { [key: string]: any }
) {

  return request<API.BaseResponseProductVO_>({
    url: "/api/product/get/vo",
    method: "GET",
    params,
    header: options?.header, // 确保正确传递 header
    ...(options || {})
  });
}

/** 获取商品详情 GET /api/product/get/vo/user */
export async function getProductVoByIdUserUsingGet(
  params: {
    id: number;
  },
  options?: { [key: string]: any }
) {

  return request<API.BaseResponseProductVO_>({
    url: "/api/product/get/vo/user",
    method: "GET",
    params,
    header: options?.header, // 确保正确传递 header
    ...(options || {})
  });
}

/** 分页获取商品列表 POST /api/product/list/page/vo */
export async function listProductVoByPageUsingPost(params: any) {
  return request<API.BaseResponsePageProductVO_>({
    url: "/api/product/list/page/vo",
    method: "POST",
    data: params
  });
}

/** 更新商品 POST /api/product/update */
export async function updateProductUsingPost(
  body: API.ProductUpdateRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>({
    url: "/api/product/update",
    method: "POST",
    data: body,
    ...options
  });
} 